package com.apkfuns.jsbridge.module;



import com.apkfuns.jsbridge.JBUtils;
import com.apkfuns.jsbridge.common.IWebView;
import ohos.agp.components.webengine.WebView;
import ohos.agp.utils.TextTool;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

/**
 * Created by pengwei on 2017/7/9.
 */

public abstract class JsListenerModule extends JsModule {

    /**
     * 执行 JS 回调方法
     * @param callPath
     * @param webView
     * @param args
     */
    protected static final void callJsListener(@NotNull String callPath, @NotNull WebView webView,
                                               @Nullable Object...args) {
        if (TextTool.isNullOrEmpty(callPath) || webView == null) {
            return;
        }
        JBUtils.callJsMethod(callPath, webView, args);
    }

    /**
     * 执行 JS 回调方法
     * @param callPath
     * @param webView
     * @param args
     */
    protected static final void callJsListener(@NotNull String callPath, @NotNull IWebView webView,
                                        @Nullable Object...args) {
        if (TextTool.isNullOrEmpty(callPath) || webView == null) {
            return;
        }
        JBUtils.callJsMethod(callPath, webView, args);
    }
}
